const BASE_URL = 'https://api-hmugo-web.itheima.net/api/public/v1';
export const myRequest = (options)=>{
	return new Promise((resolve,reject)=>{
		uni.showLoading({
			title:"加载中...",
			mask:true
		})
		uni.request({
			url:BASE_URL + options.url,
			method:options.method || 'GET',
			data:options.data || {},
			success: (res) => {
				if(res.data.meta.status != 200){
					return uni.showToast({
						title:"数据加载失败",
						icon:'none'
					})
				}
				resolve(res);
			},
			fail: (err) => {
				uni.showToast({
					title:"请求数据失败",
					icon:'none'
				})
				reject(err);
			},
			complete(error) {
				uni.hideLoading();
			}
		})
	})
}